Server_version = "v1.0";

"extDB" callExtension format["9:DATABASE:Database"];
// This causes it load Database2 Settings in the config file, if u skip this. 
//             It will crash if it attempts any database access later.

"extDB" callExtension format["9:ADD:DB_CUSTOM_v2:EWDB:EWDB"];    
"extDB" callExtension format["9:ADD:MISC:MISC"];    
// This loads DB_RAW Module & Names it fucktorndeco
//            Originally i was coding plugins, but left some code in. 
//            This way u could try and randomize the Module Names @ startup. If u are paranoid

EWDB_Loaded_version = "extDB" callExtension format["9:VERSION"];  
//"extDB" callExtension format["9:LOCK"];
// This is paranoid option, prevents loading any more options or getting extdb version info etc.
//      Basicly it disables all 9: System Calls   (there is no unlock option)




"EWDBGet" addPublicVariableEventHandler {
_data = _this select 1;
_queryResult = "extDB" callExtension format["0:EWDB:GetPlayer:%1",_data select 1];
_remove = call compile format["%1",_queryResult];
_send = _remove select 1 select 1 select 0;
EWDB = _send;
_cleintID = call compile format["%1",_data select 0];
_cleintID publicVariableClient "EWDB";};
 
 
"EWDBAdd" addPublicVariableEventHandler {
_data = _this select 1;
"extDB" callExtension format["0:EWDB:AddPlayer:%1",_data select 1];
sleep 0.25;
_queryResult = "extDB" callExtension format["0:EWDB:GetPlayer:%1",_data select 1];
_remove = call compile format["%1",_queryResult];
_send = _remove select 1 select 1 select 0;
EWDB = _send;
_cleintID = call compile format["%1",_data select 0];
_cleintID publicVariableClient "EWDB";
};
 
"EWDBUpdate" addPublicVariableEventHandler {
_data = _this select 1;
"extDB" callExtension format['0:EWDB:UpdatePlayer:%1:%2:%3',_data select 0,_data select 1 select 0,_data select 1 select 1];
};

"EWDBGUID" addPublicVariableEventHandler {
_data = _this select 1;
_queryResult = "extDB" callExtension format["0:MISC:BEGUID:%1",_data select 0];
_remove = call compile format["%1",_queryResult];
_GUID = _remove select 1;
"extDB" callExtension format['0:EWDB:UpdatePlayer:%1:guid:%2',_data select 0,_GUID];
};
 
 "EWDBJoin" addPublicVariableEventHandler {
_data = _this select 1;
_rank = _data select 0; 
_name = _data select 1; 
_score =  call compile format ["%1",_data select 2];
if ((_score <= 100) && (_rank == "")) then {} else{
_send = format ["%1 %2 Joined with a score of %3",_rank,_name,_score];
EWDBJoinMsg = _send;
publicVariable "EWDBJoinMsg";
};
};

"EWDBTracker" addPublicVariableEventHandler {
_data = _this select 1;
"extDB" callExtension format['0:EWDB:UpdateTracker:%1:%2:%3',_data select 0,_data select 1 select 0,_data select 1 select 1];
};
 
 //===================================================STATS TABLE HANDLERS=====================================================
 #include "EWDBStats.sqf";
 
 _serveridqueryResult = "extDB" callExtension format["0:EWDB:GetPlayer:0000"];
 _serveridremove = call compile format["%1",_serveridqueryResult];
_serverid = _serveridremove select 1 select 1 select 0;
 DB_Server_version = _serverid select 2;
 DB_Client_version = _serverid select 3;
publicVariable "DB_Server_version";
publicVariable "DB_Client_version";
publicVariable "Server_version";

EWDB_Loaded = "true";
publicVariable "EWDB_Loaded";
publicVariable "EWDB_Loaded_version";